<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/jsilb/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(function(){
$.ajaxSetup({async:false});
$("form").submit(function(){
	var flag;
	$.post("${pageContext.request.contextPath}/user/checkExists"
	,{"user.userName":$("[name='user.userName']").val()},function(data){
		if(data==1)
		{
			$("#msg").html("用户名已经存在，请重新输入！");
			flag=false;
		}
		else
		{
			flag=true;
		}
	});
	return flag;
	});
});
</script>
</head>
<body>
<form action="${pageContext.request.contextPath}/user/add" method="post">
<table>
<tr><td>用户名:</td><td><input type="text" name="user.userName"></td></tr>
<tr><td>密码:</td><td><input type="password" name="user.userPwd"></td></tr>
<tr><td colspan="2"><input type="submit" value="注册"></td></tr>
</table>
</form>
<div id="msg"></div>
<br>
<br>
<a href="${pageContext.request.contextPath}/main.jsp">返回主页面</a>
</body>
</html>